//
//  MLUserAccount.swift
//  SinaWeibo
//
//  Created by 李亮亮 on 16/4/9.
//  Copyright © 2016年 Big Fish. All rights reserved.
//

import UIKit

class MLUserAccount: NSObject {

    //用户授权的唯一票据
    var access_token: String?
    //access_token的生命周期，单位是秒数。
    var expires_in: NSTimeInterval = 0 {
        didSet {
            // 立即计算过期日期
            expires_date = NSDate(timeIntervalSinceNow: expires_in)
        }
    }
    //添加过期日期的字段 开发者账号的过期日期是5年,测试账号是1天
    var expires_date: NSDate?
    //标识唯一用户的id
    var uid: String?
    //用户显示名称
    var name: String?
    //用户头像 180 * 180
    var avatar_large: String?
    
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    
    override func setValue(value: AnyObject?, forUndefinedKey key: String) {}
    
    //MARK: 将对象转化为字符串
    override var description: String {
        let keys = ["access_token","avatar_large","name","uid","expires_in","expires_date"]
        let dict = dictionaryWithValuesForKeys(keys)
        return dict.description
        
    }

    
    
}
